package com.feicheng.controller.shop.admin.order;


import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.constant.Constant;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.model.OrderMain;
import com.feicheng.service.IFOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cailongyang
 * @since 2021-12-02
 */
@RestController("/shop/admin/order")
@RequestMapping("/shop/admin/order")
public class OrderController {
    @Autowired
    private IFOrderService ifOrderService;
    //门店分页查询
    @GetMapping("/page")
    public ResultInfo getOrdersByPage(OrderMain orderMain,
                                      Integer current,
                                      Integer size){
        JSONObject param = new JSONObject();
        param.put(Constant.ENTITY.ORDER.CLIENT_NAME,orderMain.getClientName());
        param.put(Constant.ENTITY.PAYMENT_RECORD.ORIGINAL_CODE,orderMain.getOriginalCode());
        param.put(Constant.ENTITY.CONSUME_RECORD.TYPE,orderMain.getType());
        param.put(Constant.ENTITY.ORDER.STATU,orderMain.getStatu());
        param.put(Constant.ENTITY.ORDER.ST,orderMain.getSt());
        param.put(Constant.ENTITY.ORDER.ET,orderMain.getEt());
        param.put(Constant.ENTITY.ORDER.STORE_ID,orderMain.getStoreId());
        param.put(Constant.ENTITY.ORDER.PHONE,orderMain.getPhone());
        param.put(Constant.HTTP.PARAM.CURRENT,current);
        param.put(Constant.HTTP.PARAM.SIZE,size);
        return ifOrderService.getOrdersByPage(param);
    }
    //根据orderId查询订单详情
    @GetMapping("/info")
    public ResultInfo getOrder(Integer orderId){
        return ifOrderService.getOrder(orderId);
    }
}
